// 定义时间过滤器，
import Vue from "vue";
Vue.filter("dateFormat", function(originDate, pattern = "") {
  // 根据给定的时间字符串，得到特定的时间
  var dt = new Date(originDate * 1000);
  //   yyyy-mm-dd
  var y = dt.getFullYear();
  var m = (dt.getMonth() + 1).toString().padStart(2, "0");
  var d = dt
    .getDate()
    .toString()
    .padStart(2, "0");
  if (pattern.toLowerCase() === "yyyy-mm-dd") {
    return `${y}-${m}-${d}`;
  } else {
    var hh = dt
      .getHours()
      .toString()
      .padStart(2, "0");
    var mm = dt
      .getMinutes()
      .toString()
      .padStart(2, "0");
    var ss = dt
      .getSeconds()
      .toString()
      .padStart(2, "0");
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
  }
});
